
/**
 * @file SourceStream.hpp
 * This class synchronizes rinex observation data streams.
 *
 * shjzhang, 2019/04/30, synchronize the data with time
 */

#ifndef GPSTK_SourceStream_HPP
#define GPSTK_SourceStream_HPP

#include <iostream>
#include <string>
#include <list>
#include <map>
#include "DataStructures.hpp"
#include "CommonHeader.hpp"

namespace gpstk
{

      /// @ingroup DataStructures
      //@{


      /** This class synchronizes rinex observation data streams.
       *
       * This class is meant to be used with the GNSS data structures objects
       * found in "DataStructures" class.
       *
       * A typical way to use this class follows:
       *
       * @code
       *
       *    SourceStream sourceStream;
       *
       *    sourceStream.setRinexObsFile("NetworkDemo/acor1480.08o");
       *
       *    sourceStream.setBeginTime(CommonTime initalTime, double sampleInterval);
       *
       *    sourceRinex gdsMap;
       *    while( sourceStream.readEpochData(gdsMap) )
       *    {
       *       // processing code here
       *
       *    }
       *
       * @endcode
       *
       * Each SourceStream object will handle a RinexObsStream object
       * for every rinex observation file of the sourceStream. 
       * 
       * The SourceStream will synchronize the observation data with  
       * the given initalTime and given sampling interval, instead of the reference
       * data in the previous version.
       *
       * By default, SourceStream object will skip the observation file failed
       * to be synchronized. When 'SourceStream::setSynchronizeException(true)'
       * is used, it'll throw a 'SynchronizeException' when faied to synchronize data.
       * Then, you must handle it appropriately.
       *
       */
    class SourceStream
    {
    public:

         /// Default constructor
        SourceStream()
        {};


         /// Default destructor
        virtual ~SourceStream()
        {};


         /// Add a rinex obs file to the sourceStream
         /// @obsFile   Rinex observation file name
        bool setRinexObsFile(const std::string& oFile);

         /// Get epoch data of the sourceStream
         /// @epoch     Epoch
         /// @gData     Object hold epoch observation data of the sourceStream
        void readEpochData( const CommonTime& epoch,
                            commonHeader& comHeader,
                            gnssRinex& gData );

        std::string getAntType()
        {
            return antType;
        };


    protected:

        std::string obsFile;
        SourceID obsSource;
        Rinex3ObsStream obsStream;
        AntexReader*  pAntexReader;
        Triple monument;
        Antenna antenna;
        std::string antType;


    }; // End of class 'SourceStream'

      //@}


}  // End of namespace gpstk

#endif   // SourceStream
